package cc.vv.btpartyjob.partymanager.delegate

import android.view.View
import android.widget.RelativeLayout
import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.moudel.bean.AddResourceObj
import cc.vv.btpartyjob.partymanager.view.ReportResourceView
import cc.vv.mvp.delegate.BaseAppDelegate
import java.util.*

/**
 * 单位报到详情托管类
 * Created by Chen.qi on 2018/10/24.
 */
class UnitReportDetailActivityDelegate : BaseAppDelegate() {

    override fun initWidget() {

    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_unit_report_detail
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_auRd_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_auRd_topBar)
        titleBar?.setEventInterface(event)
    }

    /**
     * 设置单位名称
     */
    fun setUnitName(unitName: String?) {
        val tvUnitName = getView<TextView>(R.id.tv_auRd_unitName)
        tvUnitName?.text = unitName
    }

    /**
     * 负责人姓名
     */
    fun setPrincipalName(principal: String?) {
        val tvPrName = getView<TextView>(R.id.tv_auRd_principalName)
        tvPrName?.text = principal
    }

    /**
     * 党员人数
     */
    fun setPartyPerNum(num: Int?) {
        val tvPerNum = getView<TextView>(R.id.tv_auRd_partyNum)
        tvPerNum?.text = "$num"
    }

    /**
     * 单位地址
     */
    fun setUnitAddress(address: String?) {
        val tvAddress = getView<TextView>(R.id.tv_auRd_unitAddress)
        tvAddress?.text = address
    }

    /**
     * 邮编
     */
    fun setUnitCode(code: String?) {
        val tvCode = getView<TextView>(R.id.tv_auRd_unitCode)
        tvCode?.text = code
    }


    /**
     * 报到街道
     */
    fun setStreetName(streetName: String?) {
        val tvStreet = getView<TextView>(R.id.tv_auRb_jieDaoInfo)
        tvStreet?.text = streetName
    }

    /**
     * 报到社区
     */
    fun setCommunityName(communityName: String?) {
        val tvCommunity = getView<TextView>(R.id.tv_auRb_sheQuInfo)
        tvCommunity?.text = communityName
    }

    /**
     * 报到时间
     */
    fun setReportTime(reportTime: String?) {
        val tvReportTime = getView<TextView>(R.id.tv_auRd_registerTime)
        tvReportTime?.text = reportTime
    }

    /**
     * 资源列表
     */
    fun setListData(optionList: ArrayList<AddResourceObj>?) {
        val tvReportTime = getView<ReportResourceView>(R.id.rpv_auRd_repView)
        val tvDesc = getView<TextView>(R.id.tv_auRd_desc)
        if (optionList!!.size > 0) {
            tvDesc?.visibility = View.VISIBLE
        } else {
            tvDesc?.visibility = View.GONE
        }
        tvReportTime?.addAllSelectedFileView(optionList)
    }

    /**
     * 隐藏新增资源和提交按钮
     */
    fun showAdd(isShow: Boolean) {
        val addResource = getView<RelativeLayout>(R.id.rl_auRd_addResource)
        if (isShow) {
            addResource?.visibility = View.VISIBLE
        } else {
            addResource?.visibility = View.GONE
        }
    }

    /**
     * 显示提交按钮
     */
    fun showSubmit(isShow: Boolean) {
        val submint = getView<RelativeLayout>(R.id.rl_auRd_submit)
        if (isShow) {
            submint?.visibility = View.VISIBLE
        } else {
            submint?.visibility = View.GONE
        }
    }
}